#include <bits/stdc++.h>
#define len(a) sizeof(a)/sizeof(a[0])
using namespace std;
#define ll long long
#define fill(a,x) memset(a,x,sizeof(a));
const ll m = 1e9+7;
int main(){
ll n; cin >> n;
ll a[n],m = 1e9+1;
ll d = 0,s = 0;
for(ll i = 0; i < n; i++) cin >> a[i], m = min(m,a[i]);
d = find(a,a+n,m) - a;
for(ll i = n-1; i >= 0; i--){
if(a[i] == m){
s = max(s,d);
d = 0;
}
else d += 1;
}
// cout << first << " " << last << endl;
// cout << d << endl;
cout << m*n + s;
}
729D - Sea Battle | 788A - Functions again |
1245B - Restricted RPS | 1490D - Permutation Transformation |
1087B - Div Times Mod | 1213B - Bad Prices |
1726B - Mainak and Interesting Sequence | 1726D - Edge Split |
1726C - Jatayu's Balanced Bracket Sequence | 1726A - Mainak and Array |
1613C - Poisoned Dagger | 475B - Strongly Connected City |
652B - z-sort | 124B - Permutations |
1496C - Diamond Miner | 680B - Bear and Finding Criminals |
1036E - Covered Points | 1015D - Walking Between Houses |
155B - Combination | 1531A - Зингер | color |
1678A - Tokitsukaze and All Zero Sequence | 896A - Nephren gives a riddle |
761A - Dasha and Stairs | 1728B - Best Permutation |
1728A - Colored Balls Revisited | 276B - Little Girl and Game |
1181A - Chunga-Changa | 1728C - Digital Logarithm |
1728D - Letter Picking | 792B - Counting-out Rhyme |